﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageNotificationSchedules.aspx.cs"
    Inherits="Microsoft.InformationSecurity.RiskManagement.ISRMWeb.Tasks.ManageNotificationSchedules"
    MasterPageFile="~/CISFPortal_RightMenu.Master" %>

<%@ Register Assembly="CISFAjaxExtenders" Namespace="Microsoft.InformationSecurity.CISF.Web.AjaxExtenders"
    TagPrefix="cc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/CreateNotificationSchedule.ascx" TagName="CreateNotificationSchedule"
    TagPrefix="uc1" %>
<asp:Content ID="DefaultPageContent" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
    <br />
    <div class="progressPopup">
        <asp:UpdateProgress ID="uprProgress" runat="server" DisplayAfter="200">
            <ProgressTemplate>
                <table class="progressBar" width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="center" style="width: 30%">
                            <asp:Image ID="imgUpdateProgress" ImageUrl="~/Images/LineSpinner-blue.gif" runat="server" />&nbsp;
                        </td>
                        <td>
                            <asp:Label ID="lblWaitMessage" Text="Please wait while processing data..." CssClass="messageWait"
                                Font-Bold="true" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
    <script language="javascript">
    function clearControls() {
        document.getElementById('<%=this.createNotificationSchedule.txtName.ClientID %>').value = '';
        var selectObj = document.getElementById('<%=this.createNotificationSchedule.lstNotifications.ClientID %>');
        var selectParentNode = selectObj.parentNode;
        var newSelectObj = selectObj.cloneNode(false);
        selectParentNode.replaceChild(newSelectObj, selectObj);
    }
    function setControls(name, notifications) {
        document.getElementById('<%=this.createNotificationSchedule.txtName.ClientID %>').value = name;
    }
    </script>

    <asp:UpdatePanel ID="upnlGrid" runat="server">
        <ContentTemplate>
            <table cellpadding="0" cellspacing="0" border="0" width="1020px">
                <tr>
                    <td>
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                            <tr>
                                <td align="left" valign="middle" width="40">
                                    <img src="../Images/ScheduledEmail-32.png" alt="Manage Notification Schedules" />
                                </td>
                                <td valign="middle">
                                    <asp:Label runat="server" ID="lblPageHeader" Text="" CssClass="labelPageheader"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <hr />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Button ID="btnAddNew" runat="server" Text="Add New" Width="75" OnClick="btnAddNew_OnClick" />
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                            OnRowDataBound="GridView1_OnRowDataBound" OnRowDeleting="GridView1_OnRowDeleting"
                            OnSorting="GridView1_OnSorting" OnRowEditing="GridView1_OnRowEditing" CssClass="table"
                            EmptyDataText="No notification schedules exist in the system.">
                            <AlternatingRowStyle CssClass="alternate" />
                            <EmptyDataRowStyle CssClass="emptyDataRowStyle" />
                            <Columns>
                                <asp:CommandField ShowEditButton="True" ItemStyle-Width="25" />
                                <asp:CommandField ShowDeleteButton="True" ItemStyle-Width="40" />
                                <asp:TemplateField ItemStyle-Width="100">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="btnMakeDefault" runat="server" OnCommand="btnMakeDefault_Command"
                                            CommandName="MakeDefault" CommandArgument='<%#Eval("ID")%>'>Make Default</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                    <ItemTemplate>
                                        <asp:Label ID="NameLabel" runat="server" Text='<%#Microsoft.Security.Application.AntiXss.HtmlEncode(((Microsoft.InformationSecurity.RiskManagement.ISRMWeb.NotificationsService.NotificationSchedule)Container.DataItem).Name) %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="IsDefault" HeaderText="Is Default" ReadOnly="True" SortExpression="IsDefault" />
                                <asp:BoundField DataField="TaskCount" HeaderText="Task Count" ReadOnly="True" SortExpression="TaskCount" />
                                <asp:BoundField DataField="LastUpdatedBy" HeaderText="Last Updated By" ReadOnly="True"
                                    SortExpression="LastUpdatedBy" />
                                <asp:TemplateField HeaderText="Last Updated" SortExpression="LastUpdatedDate" ItemStyle-Width="200">
                                    <ItemTemplate>
                                        <asp:Label ID="LastUpdatedLabel" runat="server" Text='<%#Eval("LastUpdatedDate") %>' />
                                        <cc2:UTCToLocalExtenderControl ID="UTCToLocalExtenderControl1" runat="server" TargetControlID="LastUpdatedLabel"
                                            DateTimeFormatString="d" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" Visible="False" />
                            </Columns>
                        </asp:GridView>
                        <br />
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnScheduleSave" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <div runat="server" id="invisbleDiv" style="visibility: hidden; display: none;">
    </div>
    <asp:Panel ID="pnlSchedule" runat="server" CssClass="modalWindow" Width="400" Height="200"
        Style="display: none;">
        <table border="0" cellpadding="1" cellspacing="2" width="100%">
            <tr>
                <td colspan="2">
                    <uc1:CreateNotificationSchedule ID="createNotificationSchedule" runat="server" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button ID="btnScheduleSave" runat="server" Text="Save" Width="75" OnClick="btnScheduleSave_Click" />
                    <asp:Button ID="btnScheduleCancel" runat="server" Text="Cancel" Width="75" />
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>
    </asp:Panel>
    <cc1:ModalPopupExtender ID="mpeSchedule" runat="server" BehaviorID="addSchedulePopup"
        TargetControlID="invisbleDiv" CancelControlID="btnScheduleCancel" OnCancelScript="clearControls();"
        PopupControlID="pnlSchedule" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
</asp:Content>
